package com.app.controller;

import com.app.model.AdminUserModel;
import com.app.model.ArticleModel;
import com.app.service.ArticleService;
import com.app.service.TownService;
import com.app.util.Result;
import com.app.util.TokenUtils;
import com.app.vo.ArticleVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@Controller
@RestController
@RequestMapping("/api")
public class TownController {
    @Autowired
    private TownService townService;
    @Autowired
    private ArticleService articleService;

    //列表
    @GetMapping("/getTownList")
    public Result<Object> getTownList() {
        return Result.success(townService.getTownList());
    }

    //根据类型查文章详情
    @GetMapping("/getArticleByType")
    public Result<Object> getArticleByType(Integer page, Integer limit, String title,Integer type,Integer cooperativeType) {
        ArticleVo articleByType = articleService.getArticleByType(page, limit, title,type,cooperativeType);
        return Result.success(articleByType);
    }

    //查看文章详情
    @GetMapping("/getArticleInfo")
    public Result<Object> getArticleInfo(Integer id) {
        return Result.success(articleService.selectById(id));
    }
}
